<!--
    挂靠公司 公共插件
    参数：对象类型
       Obj: {
                roleType: 角色类型,（枚举类型：经销商:SP ）
                contractNo: 合同号
            }
-->
<style>
    /* @import "../../../styles/common/basic-info.css"; */
</style>
<template>
    <Form class ref="anchorForm" :model="anchorForm" :label-width="100">
        <Row>
            <Col :xs="24" :md="12" :xl="6">
                <FormItem label="挂靠方式">
                    <Select v-model="anchorForm.affiliatedType" style="width:160px" disabled placeholder="挂靠方式">
                        <Option v-for="item in dataDic.affiliatedType" :value="item.value" :label="item.title"
                                :key="item.value">{{ item.title }}
                        </Option>
                    </Select>
                </FormItem>
            </Col>
            <Col :xs="24" :md="12" :xl="6">
                <FormItem label="公司名称" v-if="anchorForm.affiliatedType == 'COMPANY_AFFILIATED'">
                    <Input type="text" v-model="anchorForm.affiliatedName"
                           disabled/>
                </FormItem>
            </Col>
            <Col :xs="24" :md="12" :xl="6">
                <FormItem label="运营公司" v-if="anchorForm.affiliatedType == 'NETWORK_CAR_AFFILIATED'">
                    <Input type="text" v-model="anchorForm.affiliatedName"
                           disabled/>
                </FormItem>
            </Col>
            <Col :xs="24" :md="12" :xl="6">
                <FormItem label="个体工商户名称" v-if="anchorForm.affiliatedType == 'PERSONAL_AFFILIATED'">
                    <Input type="text" v-model="anchorForm.affiliatedName" disabled/>
                </FormItem>
            </Col>
            <Col :xs="24" :md="12" :xl="6">
                <FormItem label="统一社会信用代码">
                    <Input type="text" v-model="anchorForm.socUniCrtCode" disabled/>
                </FormItem>
            </Col>
            <Col :xs="24" :md="12" :xl="6">
                <FormItem label="网约车平台" v-if="anchorForm.affiliatedType == 'NETWORK_CAR_AFFILIATED'">
                    <Input type="text" v-model="anchorForm.cooperPlatform" disabled/>
                </FormItem>
            </Col>
        </Row>
    </Form>
</template>
<script>
    import {getCustAnchorInfo} from "_p/basic/api/contract/common/cust-anchor/cust-anchor";
    import {getByTypes} from "_p/basic/api/admin/datadic";
    import {deepClone} from "@/libs/utils/ObjectClone";
    import {channelType} from "_p/basic/api/contract/channel-type/channel-type";

    export default {
        props: {
            Obj: {
                roleType: "",
                contractNo: "",
                type: Object
            }
        },
        data() {
            return {
                dataDic: {},
                anchorForm: {},
                dicKeys: ["affiliatedType"]
            };
        },
        methods: {
            init() {

            },
            getCustAnchorInfo() {
                getCustAnchorInfo(this.Obj.contractNo, channelType(this.$route.meta.params)).then(res => {
                    if (res.code === "0000") {
                        this.anchorForm = deepClone(res.data);
                        if (res.data && res.data.affiliatedType && res.data.affiliatedType != 'NO') {
                            this.$emit('affType', true);
                        } else {
                            this.$emit('affType', false);
                        }
                    }
                });
            },
            initDataDic() {
                let self = this;
                getByTypes(this.dicKeys).then(res => {
                    if (res.code === "0000" && res.data) {
                        self.dataDic = res.data;
                    }
                });
            }
        },
        mounted() {
            this.initDataDic();
            this.getCustAnchorInfo();
            this.init();
        }
    };
</script>
